package cn.broadmax.boot.modules.sys.bean;

import cn.broadmax.boot.modules.sys.entity.SysUser;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jexx.util.StringUtil;
import lombok.Data;

@Data
@ApiModel("用户查询条件")
public class SysUserSearch{

    @ApiModelProperty("用户名")
    private String username;

    @ApiModelProperty("姓名")
    private String realName;

    @ApiModelProperty("部门ID")
    private String departmentId;

    public static LambdaQueryWrapper<SysUser> createWrap(SysUserSearch search){
        LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
        if(StringUtil.isNotEmpty(search.getUsername())){
            wrapper.like(SysUser::getUsername, search.getUsername());
        }
        if(StringUtil.isNotEmpty(search.getRealName())){
            wrapper.like(SysUser::getRealName, search.getRealName());
        }
        return wrapper;
    }

}
